export function timestampToTime(timestamp) {
  var date = new Date(timestamp);
  var Y = date.getFullYear() + "-";
  var M =
    (date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1) + "-";
  var D =
    date.getDate() < 10 ? "0" + date.getDate() + " " : date.getDate() + " ";
  var h =
    date.getHours() < 10
      ? "0" + date.getHours() + ":"
      : date.getHours() + ":";
  var m =
    date.getMinutes() < 10
    ? "0" + date.getMinutes() + ":"
    : date.getMinutes() + ":";
  var s =
    date.getSeconds() < 10 ? '0'+ date.getSeconds() : date.getSeconds();
  return Y + M + D + " " + h + m + s;
}


export default Vue => {
  Vue.filter('price', (value, length) => {
    return Number(value).toFixed(length || 2)
  })
  Vue.filter('yuanzibi', (value, n) => {
    var f = Math.floor(value*Math.pow(10,n))/Math.pow(10,n);
    var s = f.toString();
    var rs = s.indexOf('.');   
    if (rs < 0) {     
        s += '.';   
    } 
    for(var i = s.length - s.indexOf('.'); i <= n; i++){
      s += "0";
    }
    return s;
  })
  Vue.filter('orderStatus', (value,evaluateStatus) => {
    if(value<8) {
      const typeList = {
        1:'待支付',
        2:'待发货',
        3:'订单关闭',
        4:'待审核',
        5:'删除',
        7:'待收货'
      }
      return typeList[value]||''
    } else {
      const evaluateList = {
        8:'待评价',
        9:'待追评',
        10:'已追评',
        11:'过期未评价',
        12:'过期未追评'
      }
      return evaluateList[evaluateStatus]||'订单关闭'
    }
  })
}
